package com.onepice.mlp.api.controller;

import com.alibaba.fastjson.JSONObject;
import com.onepice.mlp.api.common.CommonForUser;
import com.onepice.mlp.api.config.UserProfile;
import com.onepice.mlp.core.service.GroupdService;
import com.onepice.mlp.utils.commom.ResponseResult;
import com.onepice.mlp.utils.enums.CodeType;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import jakarta.servlet.http.HttpServletRequest;

/**
 * @author FireWang
 * @date 2022/07/11 18:26:57
 */
@Slf4j
@AllArgsConstructor
@Controller
@RequestMapping("/weather")
public class WeatherController {
    private GroupdService groupService;
    private static JSONObject result;

    /**
     * 气象监测列表页
     *
     * @return
     */
    @GetMapping("/list")
    public String list(HttpServletRequest request, Model model) {
        try {
            //当前用户信息
            UserProfile userProfile = CommonForUser.getUserProfile(request);
            model = CommonForUser.getUserinfo(model, request);

            result = ResponseResult.build(CodeType.SUCCESS, "成功！");
        } catch (Exception e) {
            log.error(e.getMessage());
            result = ResponseResult.build(CodeType.FAIL, "失败：" + e.getMessage());
        }
        return "thymeleaf/weather";
    }

}
